package com.example.clxy.controller;


import com.example.clxy.entity.University;
import com.example.clxy.interceptor.AppToken;
import com.example.clxy.result.PageResult;
import com.example.clxy.result.WebRestResult;
import com.example.clxy.result.business.PageResult.UniversityPageResult;
import com.example.clxy.result.business.UniversityResult;
import com.example.clxy.service.UniversityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author Hsieh
 * @title: UniversityController
 * @projectName clxy
 * @description:
 * @date 2020/8/1021:33
 */
@AppToken
@RestController
@RequestMapping("UniversityController")
public class UniversityController {
    @Autowired
    UniversityService universityService;

    /**
    * @Author:hsieh
    * @Date: 2020/8/10 21:34
      * @param
     * @Description:添加院校
     */
    @CrossOrigin
    @PostMapping("addUniversity")
    public WebRestResult addUniversity(@RequestBody University university){
        WebRestResult result=universityService.addUniversity(university);
        return result;
    }

    @CrossOrigin
    @PostMapping("deleteUniversity")
    public WebRestResult deleteUniversity(String universityid){
        WebRestResult result=universityService.deleteUniversity(universityid);
        return result;
    }

    @CrossOrigin
    @PostMapping("updateUniversity")
    public WebRestResult updateUniversity(@RequestBody University university){
        WebRestResult result=universityService.updateUniversity(university);
        return result;
    }

    @CrossOrigin
    @RequestMapping("getUniversitybyname")
    public PageResult<UniversityPageResult> getUniversitybyname(String universityname, int page, int pagesize){
        PageResult<UniversityPageResult> result=universityService.getUniversitybyname(universityname,page,pagesize);
        return result;
    }

    @CrossOrigin
    @RequestMapping("getUniversitybyid")
    public PageResult<UniversityPageResult> getUniversitybyid(String universityid,int page, int pagesize){
        PageResult<UniversityPageResult> result=universityService.getUniversitybyid(universityid,page,pagesize);
        return result;
    }

}
